# CMakeLists.txt for MDict C++ Implementation

# 设置CMake最低版本要求
cmake_minimum_required(VERSION 3.10)

# 项目名称和版本
project(MDictParser VERSION 1.0)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 查找zlib库
find_package(ZLIB REQUIRED)

# 如果需要，可以添加LZO库的查找
# find_package(LZO REQUIRED)

# 添加源文件
set(SOURCES
    rmd128.c
    BinaryIO.cpp
    CompressionUtils.cpp
    CryptoUtils.cpp
    MDictBase.cpp
    MDX.cpp
    MDD.cpp
    # utf8.c
)

# 添加头文件
set(HEADERS
    BinaryIO.h
    CompressionUtils.h
    CryptoUtils.h
    MDictBase.h
    MDX.h
    MDD.h
    rmd128.h
    utf8.h
)

add_library(mdict ${SOURCES} ${HEADERS})
target_include_directories(mdict PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(mdict PRIVATE 
  ZLIB::ZLIB
)

# 添加可执行文件
add_executable(mdict_parser main.cpp)

# 添加包含目录
target_include_directories(mdict_parser PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# 链接zlib库
target_link_libraries(mdict_parser PRIVATE ZLIB::ZLIB
mdict
)

# 如果使用LZO库，取消下面的注释
# target_link_libraries(mdict_parser PRIVATE ${LZO_LIBRARIES})
# target_include_directories(mdict_parser PRIVATE ${LZO_INCLUDE_DIRS})

# 安装配置
install(TARGETS mdict_parser DESTINATION bin)

# 启用测试（可选）
# enable_testing()
# add_subdirectory(tests)
